//
// Created by LiuYou on 2020/8/2.
//

#ifndef CLASSWITHCOMPOSITION_CPU_H
#define CLASSWITHCOMPOSITION_CPU_H


#include <ostream>
#include "ClassInfo.h"

namespace ly {
    class Cpu : public ClassInfo {
    private:
        int speed;
    public:
        explicit Cpu(int speed = 0) : speed(speed) {}

        ~Cpu() override = default;

        int getSpeed() const {
            return speed;
        }

        void setSpeed(int speed) {
            Cpu::speed = speed;
        }

        friend std::ostream& operator<<(std::ostream& os, const Cpu& cpu) {
            os << "speed: " << cpu.speed;
            return os;
        }

        std::string toString() override {
            return (std::string) "Cpu{" +
                   "speed=" + std::to_string(speed) +
                   '}';
        }
    };

}


#endif //CLASSWITHCOMPOSITION_CPU_H
